package com.wfm.files;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

public class GenerateFile {
    public static void main(String[] args) {
        int numLines = 10000;  // 配置生成的行数
        int numElementsPerLine = 100;  // 配置每行的元素个数
        String outputFilePath ="input.txt";  // 输出文件的路径

        // 输出当前时间戳
        long start = System.currentTimeMillis();
        try (BufferedWriter writer = new BufferedWriter(new FileWriter(outputFilePath))) {
            for (int i = 0; i < numLines; i++) {
                StringBuilder lineBuilder = new StringBuilder();
                for (int j = i * numElementsPerLine + 1; j <= (i + 1) * numElementsPerLine; j++) {
                    lineBuilder.append(j);
                    if (j < (i + 1) * numElementsPerLine) {
                        lineBuilder.append(",");
                    }
                }
                writer.write(lineBuilder.toString());
                writer.newLine();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        // 输出当前时间戳
        long end = System.currentTimeMillis();
        System.out.print("生成文件耗时毫秒："+ (end-start));
    }


}